package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class ForeGroundImageView extends ImageView {
    private Drawable a;

    public ForeGroundImageView(Context arg1) {
        super(arg1);
    }

    public ForeGroundImageView(Context arg2, AttributeSet arg3) {
        this(arg2, arg3, 0);
    }

    public ForeGroundImageView(Context arg4, AttributeSet arg5, int arg6) {
        super(arg4, arg5, arg6);
        TypedArray v0 = arg4.obtainStyledAttributes(arg5, new int[]{16843017}, 0, 0);
        Drawable v1 = v0.getDrawable(0);
        if (v1 != null) {
            this.a = v1;
            this.a.setCallback(((Drawable.Callback) this));
        }

        v0.recycle();
    }

    protected void drawableStateChanged() {
        super.drawableStateChanged();
        if (this.a != null && (this.a.isStateful())) {
            this.a.setState(this.getDrawableState());
        }
    }

    protected void onDraw(Canvas arg2) {
        super.onDraw(arg2);
        if (this.a != null) {
            this.a.draw(arg2);
        }
    }

    protected void onLayout(boolean arg5, int arg6, int arg7, int arg8, int arg9) {
        super.onLayout(arg5, arg6, arg7, arg8, arg9);
        if (this.a != null) {
            this.a.setBounds(0, 0, this.getWidth(), this.getHeight());
        }
    }

    public void setForeGroundDrawable(Drawable arg3) {
        if (this.a != null) {
            this.a.setCallback(null);
        }

        this.a = arg3;
        if (this.a != null) {
            this.a.setCallback(this);
        }
    }

    protected boolean verifyDrawable(Drawable arg2) {
        boolean v0 = this.a == null || this.a != arg2 ? super.verifyDrawable(arg2) : true;
        return v0;
    }
}

